import Vue from 'vue'
import Router from 'vue-router'
import carManager from './modules/carManager'
import parkmanager from './modules/parkmanager'
import propertyManager from './modules/propertyManager'
import poleManager from './modules/poleManager'
import systemManager from './modules/systemManager'
Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '工作台', icon: 'dashboard' }
    }]
  },
  {
    path: '/add-card',
    component: () => import('@/views/carManager/components/addCard.vue'),
    name: ''
  },
  {
    path: '/addbusiness',
    component: () => import('@/views/parkManager/components/addbusiness.vue')
  },
  {
    path: '/detail',
    component: () => import('@/views/parkManager/detail.vue'),
    hidden: true,
    meta: {
      title: '查看企业'
    }
  }
]

const createRouter = () => new Router({
  mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})
export const asyncRoutes = [
  parkmanager,
  carManager,
  propertyManager,
  poleManager,
  systemManager,
  {
    path: '/systemManager/add',
    component: () => import('@/views/systemManager/add.vue'),
    name: 'add',
    meta: {
      title: '新增角色'
    },
    hidden: true
  }
]
const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
